package main

import "fmt"

func main() {
	var a interface{}
	var b int32 = 999
	a = b
	// var c int32 = a // 不能直接赋值类比java，子类可以有父类接受，但是父类不能直接转换为子类
	c, ok := a.(int64)
	if ok {
		fmt.Printf("c = %v, c 类型 = %T\n", c, c)
	} else {
		fmt.Printf("转换失败！\n")
	}
	isInt32 := fmt.Sprintf("%T", b) == "int32"
	fmt.Printf("isInt32 = %v", isInt32) // isInt32 = true

	fmt.Println("***************************")
	var i int32 = 10
	var p *int32 = &i
	fmt.Printf("p类型 = %T, p = %v, *p = %v \n", p, p, *p) // p类型 = *int32, p = 0xc0000700b8, *p = 10
	var j interface{}
	j = p
	if p2, ok := j.(*int32); ok {
		fmt.Printf("OK! *p2 = %v \n", *p2) // OK! *p2 = 10
	} else {
		fmt.Println("ERR!")
	}
}
